
package com.ibeeking.found.report.rest.controller.v1;

import com.ibeeking.found.report.rest.service.IBaseService;
import com.ibeeking.found.report.rest.service.IDataSetParamService;
import com.ibeeking.found.report.service.common.dos.DataSetParamDO;
import com.ibeeking.found.report.service.common.param.DataSetParamValidationParam;
import com.ibeeking.found.report.service.common.po.ResponseBean;
import com.ibeeking.found.report.service.common.query.DataSetParamPageQuery;
import com.ibeeking.found.report.service.common.vo.DataSetParamVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* @desc 数据集动态参数 controller
* @website https://gitee.com/anji-plus/gaea
* @author Raod
* @date 2021-03-18 12:12:33.108033200
**/
@RestController
@RequestMapping("/dataSetParam/v1")
public class DmpDataSetParamController extends DmpBaseController<DataSetParamPageQuery, DataSetParamDO, DataSetParamVO> {

    @Resource
    private IDataSetParamService dataSetParamServiceImpl;

    @Override
    public IBaseService<DataSetParamPageQuery, DataSetParamDO> getService() {
        return dataSetParamServiceImpl;
    }

    @Override
    public DataSetParamDO getEntity() {
        return new DataSetParamDO();
    }

    @Override
    public DataSetParamVO getDTO() {
        return new DataSetParamVO();
    }

    /**
     * 测试 查询参数是否正确
     * @param param
     * @return
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询参数是否正确")
    @PostMapping("/verification")
    public ResponseBean verification(@Validated @RequestBody DataSetParamValidationParam param) {
        DataSetParamVO dto = new DataSetParamVO();
        dto.setSampleItem(param.getSampleItem());
        dto.setValidationRules(param.getValidationRules());
        return responseSuccessWithData(dataSetParamServiceImpl.verification(dto));
    }
}
